function checkPhone(pole)
   {
      var W = /^[0-9]{9}$/;
      if (pole.value.match(W))
         {
            return true;
         }
      else
         {

            return false;
         }
   }
function checkFirstName(pole)
{
   if (!pole.value == " ")
      {
         return true;
      }
   else
      {

         return false;
      }
}

function checkLastName(pole)
{
   if (!pole.value == " ")
      {
         return true;
      }
   else
      {

         return false;
      }
}

function checkRegion(pole)
{
   if (!pole.value == " ")
      {
         return true;
      }
   else
      {

         return false;
      }
}

function checkQuestion1(p1check1, p1check2, p1check3, p1check4){
	if(!p1check1.checked && !p1check2.checked && !p1check3.checked && !p1check4.checked){
		return false;
	}
	return true;
}

function checkQuestion2(p2check1, p2check2, p2check3){
	if(!p2check1.checked && !p2check2.checked && !p2check3.checked){
		return false;
	}
	return true;
}

function checkQuestion5(p5check1, p5check2, p5check3, p5check4, p5check5, p5check6, p5check7, p5check8){
	if(!p5check1.checked && !p5check2.checked && !p5check3.checked && !p5check4.checked && !p5check5.checked && !p5check6.checked && !p5check7.checked && !p5check8.checked){
		return false;
	}
	return true;
}

function checkQuestion6(p6check1, p6check2, p6check3){
	if(!p6check1.checked && !p6check2.checked && !p6check3.checked){
		return false;
	}
	return true;
}

function checkQuestion7(p7check1, p7check2, p7check3, p7check4, p7check5){
	if(!p7check1.checked && !p7check2.checked && !p7check3.checked && !p7check4.checked && !p7check5.checked){
		return false;
	}
	return true;
}


function checkQuestion8(p8check1, p8check2){
	if(!p8check1.checked && !p8check2.checked ){
		return false;
	}
	return true;
}

function checkQuestion11(p10check1, p10check2, p10check3){
	if(!p10check1.checked && !p10check2.checked && !p10check3.checked){
		return false;
	}
	return true;
}

function checkTrust(pole){
	if(!pole.checked){
		return false;
	}
	return true;
}

window.onload = function()
{
   document.getElementById("form").onsubmit = function()
      {
         var tekst='';
         var p1check1 = document.getElementById("p1check1");
         var p1check2 = document.getElementById("p1check2");
         var p1check3 = document.getElementById("p1check3");
         var p1check4 = document.getElementById("p1check4");
         
         var p2check1 = document.getElementById("p2check1");
         var p2check2 = document.getElementById("p2check2");
         var p2check3 = document.getElementById("p2check3");
         
         var p5check1 = document.getElementById("p5check1");
         var p5check2 = document.getElementById("p5check2");
         var p5check3 = document.getElementById("p5check3");
         var p5check4 = document.getElementById("p5check4");
         var p5check5 = document.getElementById("p5check5");
         var p5check6 = document.getElementById("p5check6");
         var p5check7 = document.getElementById("p5check7");
         var p5check8 = document.getElementById("p5check8");
         
         var p6check1 = document.getElementById("p6check1");
         var p6check2 = document.getElementById("p6check2");
         var p6check3 = document.getElementById("p6check3");
         
         var p7check1 = document.getElementById("p7check1");
         var p7check2 = document.getElementById("p7check2");
         var p7check3 = document.getElementById("p7check3");
         var p7check4 = document.getElementById("p7check4");
         var p7check5 = document.getElementById("p7check5");
         
         var p8check1 = document.getElementById("p8check1");
         var p8check2 = document.getElementById("p8check2");
         
         var p10check1 = document.getElementById("p10check1");
         var p10check2 = document.getElementById("p10check2");
         var p10check3 = document.getElementById("p10check3");
         
         var question9 = document.getElementById("pyt9c");
         
         var phone =  document.getElementById("phone");
         var firstname =  document.getElementById("firstname");
         var lastname =  document.getElementById("lastname");
         var region = document.getElementById("location");
         
         if(!checkRegion(region)){
             tekst += "Miejsce przeprowadzenia ankiety: Nie wpisano \n";
         }
         if(!checkQuestion1(p1check1, p1check2, p1check3, p1check4)){
             tekst += "Pytanie nr 1: Niezaznoczono odpowiedzi \n";
         }
         if(!checkQuestion2(p2check1, p2check2, p2check3)){
             tekst += "Pytanie nr 2: Niezaznoczono odpowiedzi \n";
         } 
         if(!checkQuestion5(p5check1, p5check2, p5check3, p5check4, p5check5, p5check6, p5check7, p5check8)){
             tekst += "Pytanie nr 5: Niezaznoczono odpowiedzi \n";
         }
         if(!checkQuestion6(p6check1, p6check2, p6check3)){
             tekst += "Pytanie nr 6: Niezaznoczono odpowiedzi \n";
         }
         if(!checkQuestion7(p7check1, p7check2, p7check3, p7check4, p7check5)){
             tekst += "Pytanie nr 7: Niezaznoczono odpowiedzi \n";
         }
         if(!checkQuestion8(p8check1, p8check2)){
             tekst += "Pytanie nr 8: Niezaznoczono odpowiedzi \n";
         }
         if(!checkFirstName(firstname)){
             tekst += "Pytanie nr 10: Niepoprawne imie \n";
         }
         if(!checkLastName(lastname)){
             tekst += "Pytanie nr 10: Niepoprawne nazwisko \n";
         }
         if(!checkPhone(phone)){
                   tekst += "Pytanie nr 10: Niepoprawny telefon \n";
         }
         if(!checkQuestion11(p10check1, p10check2, p10check3)){
             tekst += "Pytanie nr 11: Niezaznoczono odpowiedzi \n";
         }
         if(!checkTrust(question9)){
             tekst += "Klauzula zaufania poufnosci: Nie potwierdzono \n";
         }

         if (tekst!="") {
             alert ("WYSTAPILY NASTEPUJACE BLEDY\n"+tekst);
                    return false;
         } else {
            return true;
         }

      };

};